export default {
    namespaced: true,
    actions: {
        getSuggest() {

        }
    },
    mutations: {
        openBookrack(state) {
            state.isOpenBookrack = !state.isOpenBookrack;
        },
        isLogin(state) {
            state.isLogin = !state.isLogin;
        },
        toUserPage(state) {
            state.toUserPage = !state.toUserPage;
        },
        toHome(state) {
            state.toHome = !state.toHome;
        },
        toSettingUserInfo(state) {
            state.toSettingUserInfo = !state.toSettingUserInfo;
        },
        setFromPath(state, value) {
            console.log("记录from")
            state.fromPath = value;
        },

        toWriterAction(state) {
            state.toWriter = !state.toWriter;
        },
        WriterActive(state, active) {
            state.WriterActive = active
        },
        edit(state, editBookId) {
            state.edit = !state.edit
            console.log(state, editBookId)
            state.editBookId = editBookId
        },
        //前往章节页面
        updateToChapterAction(state, info) {
            console.log("前往章节页面",info);
            
            state.toChapterAction.toPageAction = !state.toChapterAction.toPageAction;
            state.toChapterAction.chapterSort = info.chapterSort;
            if(info.bookId){
                state.toChapterAction.bookId = info.bookId;
            }
        },
        //前往书籍页面
        updateToBookAction(state, info) {
            state.toBookAction.toPageAction = !state.toBookAction.toPageAction;
            state.toBookAction.bookId = info.bookId;
        },
        //刷新头
        updateRefreshHead(state, info){
            state.refreshHead.refresh = !state.refreshHead.refresh;
        },
        updateHeadShow(state,value){
            state.headShow = value;
        }
    },
    state: {
        headShow: true,
        isOpenBookrack: false,
        isLogin: false,
        userInfo: window.sessionStorage.getItem('userInfo'),
        toUserPage: false,
        toHome: false,
        toSettingUserInfo: false,
        fromPath: "",
        toChapter: false,
        chapterId: -1,
        toWriter: false,
        //侧边栏选中的key
        WriterActive: "1",
        edit: false,
        editBookId: null,
        //前往章节页面
        toChapterAction: {
            toPageAction: false,
            chapterSort: 1,
        },
        //前往书籍页面
        toBookAction: {
            toPageAction: false,
            bookId: 1,
        },
        //刷新头
        refreshHead:{
            refresh:false,
        }
    }
}